﻿//********************************************************************************//
//创建日期：<创建日期，2016-06-16>
//创建作者：<郭登杰，guodengjie@shanghai3h.com>
//功能说明：立成财务接口
//********************************************************************************//

using System.Collections.Generic;
using Newtonsoft.Json;
using Entity;
using BLL;
using YXYLCommon;
using System.Web;
using System.Web.SessionState;
using System.Data;
using System;

namespace Web.ashx.QSSFZW
{
    public class LCCWJK : IHttpHandler, IRequiresSessionState
    {

        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            int? rsno = -1;
            string rsmsg = "";
            if (context.Request["op"] == "SC")
            {
                int zwym = int.Parse(context.Request["zwym"]);
                DbCmdResult dbrs = new DALQSZWLCCWJK().SC(zwym,BusinessTool.WType);                
                context.Response.Write(JsonConvert.SerializeObject(new JsonRs(dbrs.IsSuccess,dbrs.ReturnMsg,null)));
            }
            else if (context.Request["op"] == "HQ")
            {
                int zwym = int.Parse(context.Request["zwym"]);
                int pzlxbh = int.Parse(context.Request["pzlxbh"]);
                List<QSZWLCCWJK> list = new DALQSZWLCCWJK().HQ(zwym,pzlxbh, BusinessTool.WType);
                context.Response.Write(JsonConvert.SerializeObject(list));
            }
            else if (context.Request["op"] == "PZXX_HQ")
            {
                int zwym = int.Parse(context.Request["zwym"]);
                context.Response.Write(JsonConvert.SerializeObject(new DALQSZWLCCWJK().PZXX_HQ(zwym, BusinessTool.WType)));
            }
            else if (context.Request["op"] == "DRLC")
            {
                int zwym = int.Parse(context.Request["zwym"]);
                DataTable dt = new DALQSZWLCCWJK().DRLC_XXTQ(zwym, BusinessTool.WType, LoginInfo.CurrentUser.UserName).Tables[0];
                List<DbProcObject> poList = new List<DbProcObject>();
                foreach (DataRow item in dt.Rows)
                {
                    DbProcObject poT = new DbProcObject();
                    poT.AddSQLParameter("@DANJULX", item["DANJULX"]);
                    poT.AddSQLParameter("@DANJUMC", item["DANJUMC"]);
                    poT.AddSQLParameter("@SHIFOUDR", item["SHIFOUDR"]);
                    poT.AddSQLParameter("@DAOCHURQ", item["DAOCHURQ"]);
                    poT.AddSQLParameter("@DAORURQ", item["DAORURQ"]);
                    poT.AddSQLParameter("@DAOCHUR", item["DAOCHUR"]);
                    poT.AddSQLParameter("@DAORUR", item["DAORUR"]);
                    poT.AddSQLParameter("@GONGZUONY", item["GONGZUONY"]);
                    poT.AddSQLParameter("@PINGZHENGLXBH", item["PINGZHENGLXBH"]);
                    poT.AddSQLParameter("@SHOUFUZJLX", item["SHOUFUZJLX"]);
                    poT.AddSQLParameter("@XIANYINZJLX", item["XIANYINZJLX"]);
                    poT.AddSQLParameter("@ZHAIYAO", item["ZHAIYAO"]);
                    poT.AddSQLParameter("@KEMUDM", item["KEMUDM"]);
                    poT.AddSQLParameter("@JIEFANGJE", item["JIEFANGJE"]);
                    poT.AddSQLParameter("@DAIFANGJE", item["DAIFANGJE"]);
                    poT.AddSQLParameter("@WAIBIJFJE", item["WAIBIJFJE"]);
                    poT.AddSQLParameter("@WAIBIDFJE", item["WAIBIDFJE"]);
                    poT.AddSQLParameter("@HUILV", item["HUILV"]);
                    poT.AddSQLParameter("@JIEFANGSL", item["JIEFANGSL"]);
                    poT.AddSQLParameter("@DAIFANGSL", item["DAIFANGSL"]);
                    poT.AddSQLParameter("@DANJIA", item["DANJIA"]);
                    poT.AddSQLParameter("@FAPIAOBH", item["FAPIAOBH"]);
                    poT.AddSQLParameter("@JIESUANFS", item["JIESUANFS"]);
                    poT.AddSQLParameter("@PIAOJUBH", item["PIAOJUBH"]);
                    poT.AddSQLParameter("@BIZHONG", item["BIZHONG"]);
                    poT.AddSQLParameter("@FENLUSXH", item["FENLUSXH"]);
                    poT.AddSQLParameter("@PINGZHENGLRRQ", item["PINGZHENGLRRQ"]);
                    poT.AddSQLParameter("@HESUANDM", item["HESUANDM"]);
                    poT.AddSQLParameter("@KEHUDM", item["KEHUDM"]);
                    poT.AddSQLParameter("@KEHUMC", item["KEHUMC"]);
                    poT.AddSQLParameter("@RENYUANDM", item["RENYUANDM"]);
                    poT.AddSQLParameter("@DANJUBH", item["DANJUBH"]);
                    poT.AddSQLParameter("@PINGZHENGBH", item["PINGZHENGBH"]);
                    poT.AddSQLParameter("@ZHIDAN", item["ZHIDAN"]);
                    poT.AddSQLParameter("@FUJIAN", item["FUJIAN"]);
                    poT.AddSQLParameter("@FUHE", item["FUHE"]);
                    poT.AddSQLParameter("@SHIJIRQ", item["SHIJIRQ"]);
                    poT.AddSQLParameter("@XIANGMDM", item["XIANGMDM"]);
                    poT.AddSQLParameter("@XIANGMUMC", item["XIANGMUMC"]);
                    poT.AddSQLParameter("@BEIZHU", item["BEIZHU"]);
                    poList.Add(poT);
                }
                try
                {
                    DbCmdResult dbrs = new DALQSZWLCCWJK().DRLC(BusinessTool.WType, zwym, poList);
                    context.Response.Write(JsonConvert.SerializeObject(new JsonRs(dbrs.IsSuccess, dbrs.ReturnMsg, null)));
                }
                catch (Exception ex)
                {
                    context.Response.Write(JsonConvert.SerializeObject(new JsonRs(false,ex.Message, null)));
                }
            }
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}